<?php
namespace app\index\relevan;
use app\index\controller\Common;
use app\index\model\CertPersonModel;
use app\index\model\ContractBianListModel;
use app\index\model\ContractBianModel;
use app\index\model\ContractBuModel;
use app\index\model\ContractCaiListModel;
use app\index\model\ContractCaiModel;
use app\index\model\ContractShiModel;
use app\index\model\DealcomModel;
use app\index\model\EnginBudbianListModel;
use app\index\model\EnginBudbianModel;
use app\index\model\EnginBudgetListModel;
use app\index\model\EnginBudgetModel;
use app\index\model\EnginFoldModel;
use app\index\model\EnginModel;
use app\index\model\FileModel;
use app\index\model\FlowLogModel;
use app\index\model\StuffChuModel;
use app\index\model\StuffRuListModel;
use app\index\model\StuffRuModel;
use app\index\service\OptService;

class OtherRelevan extends Common
{


    public function vate_dealcom($minfo){
        $insarr = [];
        $insarr['name'] = $minfo['name'];
        $insarr['type'] = $minfo['type'];
        $insarr['nature'] = $minfo['nature'];
        $insarr['legaler'] = $minfo['legaler'];
        $insarr['zhuaddr'] = $minfo['zhuaddr'];
        $insarr['taxtype'] = $minfo['taxtype'];
        $insarr['ratenum'] = $minfo['ratenum'];
        $insarr['piaotype'] = $minfo['piaotype'];
        $insarr['rate'] = $minfo['rate'];
        $insarr['unitaddr'] = $minfo['unitaddr'];
        $insarr['phone'] = $minfo['phone'];
        $insarr['bankname'] = $minfo['bankname'];
        $insarr['banknum'] = $minfo['banknum'];
        $insarr['genre'] = $minfo['genre'];
        $insarr['danlevel'] = $minfo['danlevel'];
        $insarr['lianer'] = $minfo['lianer'];
        $insarr['liantel'] = $minfo['liantel'];
        $insarr['explain'] = $minfo['explain'];
        $insarr['created_user'] = $insarr['updated_user'] = $minfo['created_user'];
        $insarr['created_at'] = $insarr['updated_at']= date('Y-m-d H:i:s');

        DealcomModel::where(['id'=>$minfo['dealid']])->update($insarr);

        FileModel::where(['comid'=>$this->userinfo['comid'],'table'=>'dealcom','mid'=>$minfo['dealid']])->update(['table'=>'','mid'=>0]);
        $oldFiles = FileModel::where(['comid'=>$this->userinfo['comid'],'table'=>'dealcom_geng','mid'=>$minfo['id']])->select()->toArray();
        foreach ($oldFiles as $vvv){
            $insFile = [];
            $insFile['comid'] = $vvv['comid'];
            $insFile['table'] = 'dealcom';
            $insFile['mid'] = $minfo['dealid'];
            $insFile['name'] = $vvv['name'];
            $insFile['ext'] = $vvv['ext'];
            $insFile['size'] = $vvv['size'];
            $insFile['oripath'] = $vvv['oripath'];
            $insFile['encpath'] = $vvv['encpath'];
            $insFile['fileplain'] = $vvv['fileplain'];
            $insFile['created_user'] = $minfo['created_user'];
            $insFile['created_at'] = date('Y-m-d H:i:s');
            FileModel::insert($insFile);
        }
        FlowLogModel::insert([
            'comid' => $this->userinfo['comid'],
            'name' => '更新',
            'table' => 'dealcom',
            'mid' => $minfo['dealid'],
            'statusname' => '审核通过',
            'explain' => '',
            'created_user' => $minfo['created_user'],
            'created_at' => date("Y-m-d H:i:s")
        ]);
        return true;
    }


    public function vate_cert_perru_new($minfo){
        $insarr = $minfo;
        $insarr['created_user'] = $insarr['updated_user'] = $minfo['created_user'];
        $insarr['created_at'] = $insarr['updated_at']= date('Y-m-d H:i:s');
        $insarr['state'] = '在职';

        unset($insarr['id']);
        unset($insarr['billid']);
        unset($insarr['flowuser']);
        unset($insarr['flowdept']);
        unset($insarr['flowrelas']);
        unset($insarr['advaners']);
        unset($insarr['isturn']);
        unset($insarr['status']);

        CertPersonModel::insert($insarr);
        return true;
    }








}
